package models

import "gorm.io/gorm"

type Position struct {
	gorm.Model
	PositionName   string  `gorm:"type:varchar(40);not null;comment:职位名称"`
	Category       string  `gorm:"type:varchar(10);not null;comment:职位类别"`
	Address        string  `gorm:"type:varchar(60);not null;comment:工作地址"`
	Salary         float64 `gorm:"type:decimal(10,2);not null;comment:薪资"`
	WorkExperience string  `gorm:"type:varchar(20);not null;comment:工作经验"`
	Graduate       string  `gorm:"type:varchar(40);not null;comment:学历"`
	Info           string  `gorm:"type:varchar(50);not null;comment:职位描述"`
	UserId         int64   `gorm:"type:int(11);not null;comment:用户id"`
}

func (p *Position) AddPosition() error {
	return DB.Debug().Create(&p).Error
}

func (p *Position) UpdatePosition() error {
	return DB.Debug().Updates(&p).Error
}

func (p *Position) GetPosition(id int) error {
	return DB.Debug().Where("id = ?", id).Find(&p).Error
}

func (p *Position) DelPosition() error {
	return DB.Debug().Where("id = ?", p.ID).Delete(&p).Error
}
